﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace C4F.DevKit.WebServicesDemo
{
    public partial class DemoHost : Form
    {
        public DemoHost()
        {
            InitializeComponent();
        }

        private void DemoHost_Load(object sender, EventArgs e)
        {
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
        }

        void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            Exception ex = e.Exception;
            if (ex is System.Net.WebException)
            {
                System.Net.WebException WebEx = ex as System.Net.WebException;
                StreamReader streamReader = new StreamReader(WebEx.Response.GetResponseStream());
                string responseData = streamReader.ReadToEnd();
                streamReader.Close();
                MessageBox.Show(responseData);
            }
            else
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
